Optimal. Leaf size=63 \[ \frac {a x}{d}-\frac {2 a (c-d) \tan ^{-1}\left (\frac {d+c \tan \left (\frac {1}{2} (e+f x)\right )}{\sqrt {c^2-d^2}}\right )}{d \sqrt {c^2-d^2} f} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.07, antiderivative size = 63, normalized size of antiderivative = 1.00, number of steps
used = 4, number of rules used = 4, integrand size = 23, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.174, Rules used = {2814, 2739,
632, 210} \begin {gather*} \frac {a x}{d}-\frac {2 a (c-d) \text {ArcTan}\left (\frac {c \tan \left (\frac {1}{2} (e+f x)\right )+d}{\sqrt {c^2-d^2}}\right )}{d f \sqrt {c^2-d^2}} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 210
Rule 632
Rule 2739
Rule 2814
Rubi steps
\begin {align*} \int \frac {a+a \sin (e+f x)}{c+d \sin (e+f x)} \, dx &=\frac {a x}{d}-\frac {(a (c-d)) \int \frac {1}{c+d \sin (e+f x)} \, dx}{d}\\ &=\frac {a x}{d}-\frac {(2 a (c-d)) \text {Subst}\left (\int \frac {1}{c+2 d x+c x^2} \, dx,x,\tan \left (\frac {1}{2} (e+f x)\right )\right )}{d f}\\ &=\frac {a x}{d}+\frac {(4 a (c-d)) \text {Subst}\left (\int \frac {1}{-4 \left (c^2-d^2\right )-x^2} \, dx,x,2 d+2 c \tan \left (\frac {1}{2} (e+f x)\right )\right )}{d f}\\ &=\frac {a x}{d}-\frac {2 a (c-d) \tan ^{-1}\left (\frac {d+c \tan \left (\frac {1}{2} (e+f x)\right )}{\sqrt {c^2-d^2}}\right )}{d \sqrt {c^2-d^2} f}\\ \end {align*}
________________________________________________________________________________________
Mathematica [C] Result contains complex when optimal does not.
time = 0.21, size = 182, normalized size = 2.89 \begin {gather*} \frac {a \left (-2 (c-d) \tan ^{-1}\left (\frac {\sec \left (\frac {f x}{2}\right ) (\cos (e)-i \sin (e)) \left (d \cos \left (e+\frac {f x}{2}\right )+c \sin \left (\frac {f x}{2}\right )\right )}{\sqrt {c^2-d^2} \sqrt {(\cos (e)-i \sin (e))^2}}\right ) (\cos (e)-i \sin (e))+\sqrt {c^2-d^2} f x \sqrt {(\cos (e)-i \sin (e))^2}\right ) (1+\sin (e+f x))}{d \sqrt {c^2-d^2} f \sqrt {(\cos (e)-i \sin (e))^2} \left (\cos \left (\frac {1}{2} (e+f x)\right )+\sin \left (\frac {1}{2} (e+f x)\right )\right )^2} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A]
time = 0.26, size = 72, normalized size = 1.14
method | result | size |
derivativedivides | \(\frac {2 a \left (\frac {\arctan \left (\tan \left (\frac {f x}{2}+\frac {e}{2}\right )\right )}{d}+\frac {\left (-c +d \right ) \arctan \left (\frac {2 c \tan \left (\frac {f x}{2}+\frac {e}{2}\right )+2 d}{2 \sqrt {c^{2}-d^{2}}}\right )}{d \sqrt {c^{2}-d^{2}}}\right )}{f}\) | \(72\) |
default | \(\frac {2 a \left (\frac {\arctan \left (\tan \left (\frac {f x}{2}+\frac {e}{2}\right )\right )}{d}+\frac {\left (-c +d \right ) \arctan \left (\frac {2 c \tan \left (\frac {f x}{2}+\frac {e}{2}\right )+2 d}{2 \sqrt {c^{2}-d^{2}}}\right )}{d \sqrt {c^{2}-d^{2}}}\right )}{f}\) | \(72\) |
risch | \(\frac {a x}{d}+\frac {\sqrt {-\left (c +d \right ) \left (c -d \right )}\, a \ln \left ({\mathrm e}^{i \left (f x +e \right )}-\frac {-i c +\sqrt {-\left (c +d \right ) \left (c -d \right )}}{d}\right )}{\left (c +d \right ) f d}-\frac {\sqrt {-\left (c +d \right ) \left (c -d \right )}\, a \ln \left ({\mathrm e}^{i \left (f x +e \right )}+\frac {i c +\sqrt {-\left (c +d \right ) \left (c -d \right )}}{d}\right )}{\left (c +d \right ) f d}\) | \(124\) |
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [F(-2)]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Exception raised: ValueError} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [A]
time = 0.37, size = 237, normalized size = 3.76 \begin {gather*} \left [\frac {2 \, a f x + a \sqrt {-\frac {c - d}{c + d}} \log \left (\frac {{\left (2 \, c^{2} - d^{2}\right )} \cos \left (f x + e\right )^{2} - 2 \, c d \sin \left (f x + e\right ) - c^{2} - d^{2} + 2 \, {\left ({\left (c^{2} + c d\right )} \cos \left (f x + e\right ) \sin \left (f x + e\right ) + {\left (c d + d^{2}\right )} \cos \left (f x + e\right )\right )} \sqrt {-\frac {c - d}{c + d}}}{d^{2} \cos \left (f x + e\right )^{2} - 2 \, c d \sin \left (f x + e\right ) - c^{2} - d^{2}}\right )}{2 \, d f}, \frac {a f x + a \sqrt {\frac {c - d}{c + d}} \arctan \left (-\frac {{\left (c \sin \left (f x + e\right ) + d\right )} \sqrt {\frac {c - d}{c + d}}}{{\left (c - d\right )} \cos \left (f x + e\right )}\right )}{d f}\right ] \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [B] Leaf count of result is larger than twice the leaf count of optimal. 537 vs.
\(2 (49) = 98\).
time = 40.18, size = 537, normalized size = 8.52 \begin {gather*} \begin {cases} \frac {\tilde {\infty } x \left (a \sin {\left (e \right )} + a\right )}{\sin {\left (e \right )}} & \text {for}\: c = 0 \wedge d = 0 \wedge f = 0 \\\frac {x \left (a \sin {\left (e \right )} + a\right )}{c + d \sin {\left (e \right )}} & \text {for}\: f = 0 \\\frac {a x - \frac {a \cos {\left (e + f x \right )}}{f}}{c} & \text {for}\: d = 0 \\\frac {a x + \frac {a \log {\left (\tan {\left (\frac {e}{2} + \frac {f x}{2} \right )} \right )}}{f}}{d} & \text {for}\: c = 0 \\\frac {a d^{2} f x \tan {\left (\frac {e}{2} + \frac {f x}{2} \right )}}{d^{3} f \tan {\left (\frac {e}{2} + \frac {f x}{2} \right )} - f \left (d^{2}\right )^{\frac {3}{2}}} + \frac {2 a d^{2}}{d^{3} f \tan {\left (\frac {e}{2} + \frac {f x}{2} \right )} - f \left (d^{2}\right )^{\frac {3}{2}}} - \frac {a d f x \sqrt {d^{2}}}{d^{3} f \tan {\left (\frac {e}{2} + \frac {f x}{2} \right )} - f \left (d^{2}\right )^{\frac {3}{2}}} + \frac {2 a d \sqrt {d^{2}}}{d^{3} f \tan {\left (\frac {e}{2} + \frac {f x}{2} \right )} - f \left (d^{2}\right )^{\frac {3}{2}}} & \text {for}\: c = - \sqrt {d^{2}} \\\frac {a d^{2} f x \tan {\left (\frac {e}{2} + \frac {f x}{2} \right )}}{d^{3} f \tan {\left (\frac {e}{2} + \frac {f x}{2} \right )} + f \left (d^{2}\right )^{\frac {3}{2}}} + \frac {2 a d^{2}}{d^{3} f \tan {\left (\frac {e}{2} + \frac {f x}{2} \right )} + f \left (d^{2}\right )^{\frac {3}{2}}} + \frac {a d f x \sqrt {d^{2}}}{d^{3} f \tan {\left (\frac {e}{2} + \frac {f x}{2} \right )} + f \left (d^{2}\right )^{\frac {3}{2}}} - \frac {2 a d \sqrt {d^{2}}}{d^{3} f \tan {\left (\frac {e}{2} + \frac {f x}{2} \right )} + f \left (d^{2}\right )^{\frac {3}{2}}} & \text {for}\: c = \sqrt {d^{2}} \\- \frac {a c \log {\left (\tan {\left (\frac {e}{2} + \frac {f x}{2} \right )} + \frac {d}{c} - \frac {\sqrt {- c^{2} + d^{2}}}{c} \right )}}{d f \sqrt {- c^{2} + d^{2}}} + \frac {a c \log {\left (\tan {\left (\frac {e}{2} + \frac {f x}{2} \right )} + \frac {d}{c} + \frac {\sqrt {- c^{2} + d^{2}}}{c} \right )}}{d f \sqrt {- c^{2} + d^{2}}} + \frac {a \log {\left (\tan {\left (\frac {e}{2} + \frac {f x}{2} \right )} + \frac {d}{c} - \frac {\sqrt {- c^{2} + d^{2}}}{c} \right )}}{f \sqrt {- c^{2} + d^{2}}} - \frac {a \log {\left (\tan {\left (\frac {e}{2} + \frac {f x}{2} \right )} + \frac {d}{c} + \frac {\sqrt {- c^{2} + d^{2}}}{c} \right )}}{f \sqrt {- c^{2} + d^{2}}} + \frac {a x}{d} & \text {otherwise} \end {cases} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [A]
time = 0.48, size = 86, normalized size = 1.37 \begin {gather*} \frac {\frac {{\left (f x + e\right )} a}{d} - \frac {2 \, {\left (\pi \left \lfloor \frac {f x + e}{2 \, \pi } + \frac {1}{2} \right \rfloor \mathrm {sgn}\left (c\right ) + \arctan \left (\frac {c \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) + d}{\sqrt {c^{2} - d^{2}}}\right )\right )} {\left (a c - a d\right )}}{\sqrt {c^{2} - d^{2}} d}}{f} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [B]
time = 7.39, size = 449, normalized size = 7.13 \begin {gather*} \frac {2\,a\,\mathrm {atan}\left (\frac {\sin \left (\frac {e}{2}+\frac {f\,x}{2}\right )}{\cos \left (\frac {e}{2}+\frac {f\,x}{2}\right )}\right )}{f\,\left (c+d\right )}-\frac {2\,a\,\mathrm {atanh}\left (\frac {3\,d^2\,\sin \left (\frac {e}{2}+\frac {f\,x}{2}\right )\,{\left (d^2-c^2\right )}^{3/2}-2\,c^4\,\sin \left (\frac {e}{2}+\frac {f\,x}{2}\right )\,\sqrt {d^2-c^2}-2\,c^2\,\sin \left (\frac {e}{2}+\frac {f\,x}{2}\right )\,{\left (d^2-c^2\right )}^{3/2}+d^4\,\sin \left (\frac {e}{2}+\frac {f\,x}{2}\right )\,\sqrt {d^2-c^2}+2\,c^2\,d^2\,\cos \left (\frac {e}{2}+\frac {f\,x}{2}\right )\,\sqrt {d^2-c^2}+3\,c^2\,d^2\,\sin \left (\frac {e}{2}+\frac {f\,x}{2}\right )\,\sqrt {d^2-c^2}+c\,d\,\cos \left (\frac {e}{2}+\frac {f\,x}{2}\right )\,{\left (d^2-c^2\right )}^{3/2}+c\,d^3\,\cos \left (\frac {e}{2}+\frac {f\,x}{2}\right )\,\sqrt {d^2-c^2}+c^3\,d\,\cos \left (\frac {e}{2}+\frac {f\,x}{2}\right )\,\sqrt {d^2-c^2}+4\,c\,d^3\,\sin \left (\frac {e}{2}+\frac {f\,x}{2}\right )\,\sqrt {d^2-c^2}-2\,c^3\,d\,\sin \left (\frac {e}{2}+\frac {f\,x}{2}\right )\,\sqrt {d^2-c^2}}{2\,\left (d^2+c\,d\right )\,\left (\cos \left (\frac {e}{2}+\frac {f\,x}{2}\right )\,c^3+2\,\sin \left (\frac {e}{2}+\frac {f\,x}{2}\right )\,c^2\,d-\cos \left (\frac {e}{2}+\frac {f\,x}{2}\right )\,c\,d^2-2\,\sin \left (\frac {e}{2}+\frac {f\,x}{2}\right )\,d^3\right )}\right )\,\sqrt {d^2-c^2}}{d\,f\,\left (c+d\right )}+\frac {2\,a\,c\,\mathrm {atan}\left (\frac {\sin \left (\frac {e}{2}+\frac {f\,x}{2}\right )}{\cos \left (\frac {e}{2}+\frac {f\,x}{2}\right )}\right )}{d\,f\,\left (c+d\right )} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________